package com.seven.config;

import com.seven.component.LoginHandlerInterceptor;
import org.springframework.web.servlet.config.annotation.*;

import java.util.List;

/**
 * spring mvc 相关自定义配置
 * @Author seven
 * @Date 2020/4/27 13:17
 **/

public class MyWebMvcConfigurer implements WebMvcConfigurer {

    /**
     * 视图控制器
     * @param registry
     * addViewController请求路径
     * setViewName 跳转路径
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/main.html").setViewName("dashboard");
    }

    /**
     * 添加拦截器
     * @param registry
     * addInterceptor(拦截器).addPathPatterns(拦截路径).excludePathPatterns(不拦截路径)
     */
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
//                .excludePathPatterns("/index.html","/","/user/login","/asserts/**","/webjars/bootstrap/**");
//    }
}
